package com.warm.micro.consumer.config;

import feign.Contract;
import org.springframework.cloud.openfeign.support.SpringMvcContract;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Date: 2020/5/9 10:20
 * @Author: LChuang
 * @Description: Feign 配置类
 */
@Configuration
public class FeignConfig {

    /**
     * 该类为Feign的配置类
     * 注意：该类不应该在主应用程序上下文的@CompantScan中
     *      Application 启动类默认扫描当前包下的所有子包
     *  启动类加注解 排除扫描 -->
     *    @ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {FeignConfig.class})})
     *
     * 可自定义的内容:
     *   编解码器
     *   日志服务
     *   Contract (默认使用契约 SpringMVCContract)
     */
    /**
     * Configurations:
     *    Type          |    Default
     *   feignDecoder  ---  ResponseEntityDecoder
     *   feignEncoder  ---  SpringEncoder
     *   feignLogger   ---  Slf4jLogger
     *   feignContract ---  SpringMvcContract      * 契约 *
     *   feignBuilder  ---  HystrixFeign.Builder
     *   feignClient   ---  LoadBalancerFeignClient(Ribbon) / feignClient(Other)
     */
    @Bean
    public Contract contract(){

        /**  用feign.Contract.Default 替换 SpringMvcContract契约 */
        // return new Contract.Default();
        return new SpringMvcContract();
    }
}
